import dbus
import omg_types

def getUnlockedTrophies():

    session_bus = dbus.SessionBus()
    proxy = session_bus.get_object ('org.gnome.omg', '/org/gnome/omg/trophies');

    omg = dbus.Interface(proxy, 'org.gnome.omg.trophies')

    set_names = omg.GetAllSetNames();
    trophies_per_set = {}

    for set_name in set_names:

        dbus_trophies = omg.GetTrophyBySet(str(set_name))
        trophies = []

        for t in dbus_trophies:
            trophy = omg_types.new_trophy_from_dbus(t)

            if(trophy.Unlocked == True):
                trophies.append(trophy)

        trophies_per_set[str(set_name)] = trophies

    return trophies_per_set

def main():
    t = getUnlockedTrophies();

    for i in t.values():
        print i.__str__()

if __name__=="__main__":
    main()
